package com.zhoun.controller.backend;

import com.zhoun.common.ServerResponse;
import com.zhoun.pojo.Category;
import com.zhoun.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/manage/category")
public class CategoryManageController {

    @Autowired
    private CategoryService categoryService;

    @RequestMapping("/list")
    @ResponseBody
    public ServerResponse list(){
        return categoryService.getCategoryList();
    }

    @RequestMapping("/addOrUpdate")
    @ResponseBody
    public ServerResponse addOrUpdate(Category category){
        return categoryService.addOrUpdate(category);
    }

    @RequestMapping("/delete")
    @ResponseBody
    public ServerResponse delete(Integer categoryId){
        return categoryService.delete(categoryId);
    }

    @RequestMapping("/getCategoryById")
    @ResponseBody
    public ServerResponse getCategoryById(Integer categoryId){
        return categoryService.getCategoryById(categoryId);
    }

}
